package logic

import (
	"context"
	"errors"
	"video-hub/models/mysql"

	"video-hub/videorpc/internal/svc"
	"video-hub/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MenListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMenListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MenListLogic {
	return &MenListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *MenListLogic) MenList(in *videorpc.MenListRequest) (*videorpc.MenListResponse, error) {
	// todo: add your logic here and delete this line
	var menList []*videorpc.MenList
	menList = mysql.MenList(mysql.DB, in)

	if in.Size >= 10 {
		return nil, errors.New("已显示全部评论")
	}

	return &videorpc.MenListResponse{
		MenList: menList,
	}, nil
}
